<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收集表单数据</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="demo">
    <form action="/xxxx" @submit.prevent="handleSubmit">
        <span>用户名：</span><input type="text" v-model="username"><br>
        <span>密码：</span><input type="password" v-model="pwd"><br>
        <span>性别：</span><input type="radio" id="female" value="female" v-model="sex">
        <label for="female">女</label><input type="radio" value="male" id="male" v-model="sex">
        <label for="male">男</label><br>
        <span>爱好：</span>
        <input type="checkbox" id="basket" value="basket" v-model="likes"><label for="basket">篮球</label>
        <input type="checkbox" id="foot" value="foot" v-model="likes"><label for="foot">足球</label>
        <input type="checkbox" id="pingpang" value="pingpang" v-model="likes"><label for="pingpang">乒乓球</label><br>
        <span>城市：</span>
        <select v-model="checkCity">
            <option value="">未选择。。。</option>
            <option :value="city.id" v-for="(city,index) in allCities">{{city.name}}</option>
        </select><br>
        <span>介绍：</span>
        <textarea v-model="ta" style="width: auto"></textarea>
        <input type="submit">
    </form>
</div>
<script type="text/javascript">
    const vm = new Vue({
        el: '#demo',
        data:{
            username:'ywh',
            pwd: '',
            sex:'',
            likes:[],
            allCities:[{id:1,name:'BJ'},{id:2,name:'SH'},{id:3,name:'QD'}],
            checkCity:[],
            ta:''
        },
        methods:{
            handleSubmit(){
                console.log(this.username,this.pwd,this.sex,this.likes)
            }
        }
    });
</script>
</body>
</html>